package io.geekidea.springbootplus.system.service.impl;

import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.system.entity.SysComment;
import io.geekidea.springbootplus.system.mapper.SysCommentMapper;
import io.geekidea.springbootplus.system.service.SysCommentService;
import io.geekidea.springbootplus.system.vo.SysCommentQueryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class SysCommentServiceImpl extends BaseServiceImpl<SysCommentMapper,SysComment> implements SysCommentService {

    @Autowired
    private SysCommentMapper sysCommentMapper;


    @Override
    public List<SysCommentQueryVo> getSysCommentByProductId(long productId) throws Exception {
        return sysCommentMapper.getSysCommentByProductId(productId);
    }

    @Override
    public boolean addSysComment(SysComment sysComment) throws Exception{
        return sysCommentMapper.insertSysComment(sysComment) > 0;
    }

    @Override
    public boolean deleteSysCommentByOrderId(Integer orderId) throws Exception {
        return sysCommentMapper.deleteSysCommentByOrderId(orderId) > 0;
    }
}
